$(document).ready(function(){
                  //PMLP
                  
                  //Links to divs in Adding resource dialog
                  var divs = new Array();
                  divs[Editor.PML.PREFIX+Editor.PML.SOURCE] ="catinfo";
                  divs[Editor.PML.PREFIX+Editor.PML.INFERENCE] ="catinfer";
                  divs[Editor.PML.PREFIX+Editor.PML.AGENT] ="catagent";
                  divs[Editor.PML.PREFIX+Editor.PML.SOFTWARE] ="catsoftware";

                  var backdivs = new Array();
                  backdivs["maincat"]=null;
                  backdivs["catinfo"] ="maincat";
                  backdivs["catagent"] ="catinfo";
                  backdivs["catsoftware"] ="catagent";
                  //First level
                  $("input[name='pmlclass']")[0].value = Editor.PML.PREFIX+Editor.PML.INFORMATION;
                  $("input[name='pmlclass']")[1].value = Editor.PML.PREFIX+Editor.PML.SOURCE;
                  $("input[name='pmlclass']")[2].value = Editor.PML.PREFIX+Editor.PML.INFERENCE;
                  $("input[name='pmlclass']")[3].value = Editor.PML.URI;
                  //Other levels
                  $("input[name='pmlclass']")[4].value = Editor.PML.PREFIX+Editor.PML.AGENT;
                  $("input[name='pmlclass']")[5].value = Editor.PML.PREFIX+Editor.PML.DOCUMENT;
                  $("input[name='pmlclass']")[6].value = Editor.PML.PREFIX+Editor.PML.DOCUMENTFRAGMENT;
                  $("input[name='pmlclass']")[7].value = Editor.PML.PREFIX+Editor.PML.ORGANIZATION;
                  $("input[name='pmlclass']")[8].value = Editor.PML.PREFIX+Editor.PML.PERSON;
                  $("input[name='pmlclass']")[9].value = Editor.PML.PREFIX+Editor.PML.SENSOR;
                  $("input[name='pmlclass']")[10].value = Editor.PML.PREFIX+Editor.PML.SOFTWARE;
                  $("input[name='pmlclass']")[11].value = Editor.PML.PREFIX+Editor.PML.INFERENCEENGINE;
                  $("input[name='pmlclass']")[12].value = Editor.PML.PREFIX+Editor.PML.WEBSERVICE;

                  $("input[name='pmlclass']")[13].value = Editor.PML.PREFIX+Editor.PML.DECLARATIVE;
                  $("input[name='pmlclass']")[14].value = Editor.PML.PREFIX+Editor.PML.METHOD;
                  $(".pmlRadio").hide();
                  $("#maincat").show();
                  
                  
                  //PMLJ
                  divs[Editor.PML.J.PREFIX+Editor.PML.J.JELEMENT] ="catjustif";
                  divs[Editor.PML.J.PREFIX+Editor.PML.J.MAPPING] ="maincatJ";
                  
                  //First level
                  $("input[name='pmlJclass']")[0].value = Editor.PML.J.PREFIX+Editor.PML.J.MAPPING;
                  $("input[name='pmlJclass']")[1].value = Editor.PML.J.PREFIX+Editor.PML.J.JELEMENT;
                  $("input[name='pmlJclass']")[2].value = Editor.PML.J.PREFIX+Editor.PML.J.NODESETLIST;
                  //Other levels
                  $("input[name='pmlJclass']")[3].value = Editor.PML.J.PREFIX+Editor.PML.J.INFERENCESTEP;
                  $("input[name='pmlJclass']")[4].value = Editor.PML.J.PREFIX+Editor.PML.J.NODESET;
                  $("input[name='pmlJclass']")[5].value = Editor.PML.J.PREFIX+Editor.PML.J.QUERY;
                  $("input[name='pmlJclass']")[6].value = Editor.PML.J.PREFIX+Editor.PML.J.QUESTION;
                  $(".pmljRadio").hide();
                  $("#maincatJ").show();
                  
                  //PMLT
                  divs[Editor.PML.T.PREFIX+Editor.PML.T.BELIEFELEMENT] ="catbelief";
                  divs[Editor.PML.T.PREFIX+Editor.PML.T.TRUSTELEMENT] ="cattrust";
                  
                  //First level
                  $("input[name='pmlTclass']")[0].value = Editor.PML.T.PREFIX+Editor.PML.T.BELIEFELEMENT;
                  $("input[name='pmlTclass']")[1].value = Editor.PML.T.PREFIX+Editor.PML.T.TRUSTELEMENT;
                  //Other levels
                  $("input[name='pmlTclass']")[2].value = Editor.PML.T.PREFIX+Editor.PML.T.FLOATBELIEF;
                  $("input[name='pmlTclass']")[3].value = Editor.PML.T.PREFIX+Editor.PML.T.FLOATTRUST;
          
                  $(".pmltRadio").hide();
                  $("#maincatT").show();
                  
                  // Copying to URL in PMLP
                  $('#name').keyup(function() { $("#namespaceUri").val($("#namespacePrefix").val()+$("#name").val());
                                   });
                  $('#namespacePrefix').keyup(function() { $("#namespaceUri").val($("#namespacePrefix").val()+$("#name").val());
                                              });

                  // Copying to URL in PMLJ
                  $('#nameJ').keyup(function() { $("#namespaceUriJ").val($("#namespacePrefixJ").val()+$("#nameJ").val());
                                   });
                  $('#namespacePrefixJ').keyup(function() { $("#namespaceUriJ").val($("#namespacePrefixJ").val()+$("#nameJ").val());
                                              });
                  
                  
                  // Copying to URL in PMLT
                  $('#nameT').keyup(function() { $("#namespaceUriT").val($("#namespacePrefixT").val()+$("#nameT").val());
                                   });
                  $('#namespacePrefixT').keyup(function() { $("#namespaceUriT").val($("#namespacePrefixT").val()+$("#nameT").val());
                                               });
                  
                  
                  
                  //main function for displaying
                  
                  function displayDivs(classname, suffix){
                    newvalue = $("input[name='"+classname+"']:checked").val();
                    speed =200 ;
                    $("#lastType").val(newvalue);
                    aux = divs[newvalue];
                    if(aux != null){
                      selecteddiv = $("input[name='"+classname+"']:checked").parent().attr("name");
                      
                      
                    }else{
                      aux = $("input[name='"+classname+"']:checked").parent().attr("name");;
                    }
                    if(selecteddiv != 'maincat'+suffix && selecteddiv != aux){
                      speed = 0;
                    }else{
                      speed=300;
                    }
                    $("div.pml"+suffix+"Radio[name!=maincat"+suffix+"]").hide(speed);
                    
                    $("input[name='"+classname+"']:checked").parent().show(speed);
                    
                    $("div[name=maincat]").show();
                    $("div[name="+aux+"]").show('fast');
                    var aux2;
                    while((aux2 = backdivs[aux])!=null){
                      $("div[name="+aux+"]").show(0);
                      aux = aux2;
                    }
                  }
                  
                  //Menu display for PMLP
                  $("input[name='pmlclass']").change( function(){displayDivs('pmlclass', '')});

                  
                  //Menu display for PMLJ
                  $("input[name='pmlJclass']").change(function(){displayDivs('pmlJclass', 'J')});


                  //Menu display for PMLT
                  $("input[name='pmlTclass']").change(function(){displayDivs('pmlTclass', 'T')});
                  
                  
                  //Hide options if blank node
                  
                  
                  
                  $("#isBlank").change(function(){
                                       if( $("#isBlank").is(':checked')){
                                       Editor.Util.blankDialogOn();
                                       }else{
                                         Editor.Util.blankDialogOff();
                                       }
                  });
                  
                  $("#isBlankJ").change(function(){
                                       if( $("#isBlankJ").is(':checked')){
                                       Editor.Util.blankDialogPMLJOn();
                                       }else{
                                         Editor.Util.blankDialogPMLJOff();
                                       }
                  });


                  $("#isBlankT").change(function(){
                                       if( $("#isBlankT").is(':checked')){
                                       Editor.Util.blankDialogPMLTOn();
                                       }else{
                                         Editor.Util.blankDialogPMLTOff();
                                       }
                  });                  
                  
});
